<?php
/*
Template Name: Blog  - Full Width
*/
get_header(); ?>

<?php if ( have_posts() ) while ( have_posts() ) : the_post(); 

    $content = get_the_content();
	$title = get_the_title();
	
	// Posts per page
	$posts_per_page = get_post_meta($post->ID, 'posts_per_page', true);
	if ( $posts_per_page == '' ) $posts_per_page = '-1';
	
endwhile; ?>

<?php $blogs = get_blogs(); 

foreach ($blogs as $blog):
	if (is_page($blog->page)): ?>
	
    	<section id="content_wrapper" class="clearfix">
            <h1 class="page_title">
                <?php echo $title; ?>
            </h1>
            <div class="page_content">
                <?php the_content(); ?>
            </div><!-- .page_content -->
                            
            <?php
			
			if ( is_front_page() )
				$paged = ( get_query_var('paged') ) ? get_query_var('paged') : ( get_query_var('page') ) ? get_query_var('page') : 1;
            
            $current_categories = $blog->category;
            $wp_query = new WP_Query('post_type=post&posts_per_page='.$posts_per_page.'&cat='.$current_categories.'&paged='.$paged);

            global $more;
            $more = 0;
            
            if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post();
                
                if ( has_post_thumbnail() )
				{
					$thumbnail_src = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
                
					$thumbnail_size = 'w=450&amp;h=250';
					$image_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100';
					$image_background_source = get_template_directory_uri().'/includes/timthumb.php?src='.$thumbnail_src.'&amp;'.$thumbnail_size.'&amp;zc=1&amp;q=100&amp;f=2|8|8|8|8|8|8|8';
				}
                            
                echo '<article class="blog_full_width clearfix">';

					if ( has_post_thumbnail() )
					{
						echo '<a class="blog_image" href="'; the_permalink(); echo '">';
							echo '<div class="zoom">';
								echo '<span></span>';
							echo '</div>';
							echo '<div class="on_top" style="background: url(\''; echo $image_source; echo '\');"></div>';
							echo '<div class="on_middle" style="background: url(\''; echo $image_background_source; echo '\');"></div>';
							echo '<div class="above_bottom" style="background: url(\''; echo $image_source; echo '\');"></div>';
							echo '<div class="on_bottom"></div>';
						echo '</a>';
					}
						
					echo '<div class="blog_content clearfix"'; if ( !has_post_thumbnail() ) echo ' style="width: 960px !important;"'; echo '>';
						echo '<div class="heading">';
							echo '<a href="'; the_permalink(); echo '">';
								echo '<h3>';
									echo the_title();
								echo '</h3>';
							echo '</a>';
						echo '</div>';
						echo '<div class="text">';
							echo the_content('');
						echo '</div>';
						
						echo '<div class="read_more">';
							echo '<a href="'; the_permalink(); echo '">';
								echo '<span class="read_more_arrow"></span>';
								echo __( 'Read more', 'reFresh' );
							echo '</a>';
						echo '</div>';
						
						echo '<div class="meta clearfix">';
							echo '<div class="date">';
								echo __( 'Posted on: ', 'reFresh' ); echo get_the_date('d M Y'); 
							echo '</div>';
							
							echo '<div class="posted_by">';
								echo __( 'Posted by: ', 'reFresh' );	the_author();
								echo ', Comments: '; comments_number('0', '1', '%');
							echo '</div>';
						echo '</div>';
						
                    echo '</div>'; // .blog_content

               echo '</article>';


            endwhile; endif;
            
            if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
            
            ?>
            
        </section> <!-- #content_wrapper -->
    
	<?php get_footer(); 

	return;
	endif;
endforeach;
?>









